﻿@model IEnumerable<KCMS.BusinessLogic.Models.Order>

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table>
    <tr>
        <th>
            Client
        </th>
          <th>
            Organization
        </th>
        <th>
            Первоначальная<br>сумма, руб.
        </th>
        <th>
            Текущая<br>сумма, руб.
        </th>
        <th>
            Number
        </th>
        <th>
            Delivery
        </th>
        <th>
            Status&nbsp;&nbsp;&nbsp;Date
        </th>
        
        <th></th>
    </tr>

@foreach (var item in Model)
{
    <tr>
        <td>
          <a href="@Url.Action("Details", "Client", new { id = item.Client.Id })">@item.Client.Title</a>
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Client.Organization)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Total)
        </td>
         <td>
           @{Html.RenderAction("GetTotalByOrder", "OrderItem", new { orderId = item.Id });}
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Number)
        </td>
          <td>
         @Html.DisplayFor(modelItem=>item.Delivery.Title)
        </td>
         <td>
            @{Html.RenderAction("GetOrderStatus", new { orderId = @item.Id });}
        </td>
       
        <td>
            @Html.ActionLink("Details", "Details", new { id=item.Id }) |
              @Html.ActionLink("History", "History", new { id=item.Id }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.Id })
        </td>
    </tr>
}

</table>
